//
//  SinaSearchView.swift
//  SinaWeiBo
//
//  Created by 王忠楠 on 16/9/19.
//  Copyright © 2016年 wangzn. All rights reserved.
//

import UIKit

class SinaSearchView: UIView {

    @IBOutlet weak var searchTextFieldRightConstraint: NSLayoutConstraint!
   
    @IBOutlet weak var searchButton: UIButton!
    
    
    @IBOutlet weak var textField: SinaTextField!
    
    
    @IBAction func editBeginAction(_ sender: AnyObject) {
        
        searchTextFieldRightConstraint.constant = searchButton.width
        
        UIView.animate(withDuration: 0.3){
            self.layoutIfNeeded()
        }
        
    }
    
    
    
    @IBAction func searchButtonAction(_ sender: AnyObject) {
        
      textField.resignFirstResponder()
        searchTextFieldRightConstraint.constant = 0
        UIView.animate(withDuration: 0.3){
            self.layoutIfNeeded()
        }
        
    }
    
    
    //使用类方法创建Xib
    class func searchView() -> SinaSearchView{
        
        
        return UINib(nibName: "SinaSearchView", bundle: nil).instantiate(withOwner: nil, options: nil).last! as!
        SinaSearchView
        
    }
    
    override func awakeFromNib() {
        
        textField.layer.borderColor = UIColor.magenta.cgColor
        textField.layer.borderWidth = 2
        textField.layer.cornerRadius = 5
        textField.layer.masksToBounds = true
        
        
    }
    
    
    
}
